package com.blog.controller;

import com.blog.product.Product;
import com.blog.service.ProductSevice;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName ProductController
 * @Destription
 * @Author 天堂小野花
 * @Date 2025/7/31  21:58
 * @Version 1.0
 */
@RestController
public class ProductController {
    @Autowired
    ProductSevice productService;

    @GetMapping("/product/{id}")
    public Product getProduct(@PathVariable("id") Integer id,
                              HttpServletRequest httpServletRequest){
        String header = httpServletRequest.getHeader("X-Token");
        /*try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {0
            throw new RuntimeException(e);
        }*/
        System.out.println("header = " + header);
        System.out.println("hello");
        Product product = productService.getProductById(id);
        return product;
    }
}
